Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable limiting polymorphic relations to only certain types #1817

Merged
merged 12 commits into from
Dec 8, 2023
Merged

Conversation

benjie
Copy link
Member

@benjie benjie commented Oct 13, 2023

Description

Adds an only argument (an enum list) to some polymorphic relation fields (currently only those for lists/connections of "mode=union" interfaces). When present, only the given types will be included in the result.

Currently this is enabled by default but marked as experimental. Due to #1816 Ruru won't recognize the argument exists, but it's there so just write it and ignore the red squigglies. The enum values are the exact names of the types.

Example query:

{
  allApplications(only: [GcpApplication, AwsApplication]) {
    nodes {
      __typename
      ... on AwsApplication {
        awsId
      }
      ... on GcpApplication {
        gcpId
      }
      vulnerabilities(only: [ThirdPartyVulnerability]) {
        nodes {
          __typename
          id
          name
          ... on FirstPartyVulnerability {
            teamName
          }
          ... on ThirdPartyVulnerability {
            vendorName
          }
        }
      }
    }
  }
}

Performance impact

Plan-time only.

Security impact

None known.

Checklist

  • My code matches the project's code style and yarn lint:fix passes.
  • I've added tests for the new feature, and yarn test passes.
  • I have detailed the new feature in the relevant documentation.
  • I have added this feature to 'Pending' in the RELEASE_NOTES.md file (if one exists).
  • If this is a breaking change I've explained why.

@changeset-bot
Copy link

changeset-bot bot commented Oct 13, 2023

🦋 Changeset detected

Latest commit: f305c32

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
graphile-build-pg Patch
postgraphile Patch
@dataplan/pg Patch
graphile-build Patch
graphile-utils Patch
pgl Patch
graphile Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@benjie benjie marked this pull request as ready for review December 8, 2023 10:36
…e of them, specifically `pgUnionAll()` right now) to limit the types of their results; exposed via an experimental 'only' argument on fields, for example `allApplications(only: [GcpApplication, AwsApplication])` would limit the type of applications returned to only be the two specified.
@benjie benjie merged commit 4ed8d79 into main Dec 8, 2023
24 checks passed
@benjie benjie deleted the limit-poly branch December 8, 2023 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

1 participant